import { Module, forwardRef } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import jwtConfig from '../../config/jwt.config';
import { MessagesService } from './messages.service';
import { MessagesController } from './messages.controller';
import { Message } from './entities/message.entity';
import { Notification } from './entities/notification.entity';
import { Conversation } from './entities/conversation.entity';
import { User } from '../auth/entities/user.entity';
import { Friendship } from '../friends/entities/friendship.entity';
import { NotificationsModule } from '../notifications/notifications.module';

@Module({
  imports: [
    TypeOrmModule.forFeature([
      Message,
      Notification,
      Conversation,
      User,
      Friendship,
    ]),
    jwtConfig, // 导入 JWT 模块
    NotificationsModule, // 导入 WebSocket 通知模块
  ],
  controllers: [MessagesController],
  providers: [MessagesService],
  exports: [MessagesService], // 导出服务供其他模块使用（如自动创建通知）
})
export class MessagesModule {}
